-
Notifications
You must be signed in to change notification settings - Fork 16
Add Model Name and System Fingerprint to llm_output
in _convert_response_to_chat_result
#84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Enhance ChatResult output with model details and token usage
usage = response.get("usage", {}) | ||
return ChatResult(generations=generations, llm_output=usage) | ||
llm_output = { | ||
"token_usage": response.get("usage", {}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename this to usage so it doesn't change the API for existing users?
"token_usage": response.get("usage", {}), | |
"usage": response.get("usage", {}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did as @bbqiu suggested, so usage
remains intact
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also created a new unit test, since the existing ones were not altered by this change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also update tests here: https://github.com/databricks/databricks-ai-bridge/blob/main/integrations/langchain/tests/unit_tests/test_chat_models.py#L84
Thank you for contributing. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
Please reapprove, I fixed the linting error ( P.S. I'm confused about this particular linting error: did you change the linting configuration recently? Otherwise it doesn't make sense to me |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approving to unblock merge
This PR enhances
_convert_response_to_chat_result
by including the model name and system fingerprint inllm_output
. The model name is particularly important for observability tools like LangFuse, which rely onllm_output["model_name"]
for tracking.Currently, Databricks does not provide the model name in the metadata—only the endpoint name. This change ensures that external models are properly identified, improving observability and logging.
Changes:
model_name
tollm_output
, defaulting toself.model
if not in the response.system_fingerprint
tollm_output
for additional metadata.llm_output
to includetoken_usage
separately for better structure.Why?
When using external models with Databricks, the returned metadata only includes the endpoint name, not the actual model name. This change allows users to extract the correct model name for logging and monitoring.
Testing:
self.model
ifresponse["model"]
is missing.